//
//  CYReleaceDetailVC.m
//  CreditAddressBook
//
//  Created by Mosu&Cuu on 16/4/15.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYReleaceDetailVC.h"
#import "CYURL.h"
#import "CYPersonReModel.h"
#import "UIImageView+WebCache.h"
#import "LEBarButtonItem.h"
#import "CYLoginHttpTool.h"
#import "CYUser.h"
#import "CYJsonInfo.h"
#import "CYCommonReleaseTVC.h"
#import "NSObject+MJKeyValue.h"
#import "CYJumpsTool.h"


@interface CYReleaceDetailVC ()
@property (weak, nonatomic) IBOutlet UIImageView *headimageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLab;
@property (weak, nonatomic) IBOutlet UILabel *phoneLab;
@property (weak, nonatomic) IBOutlet UILabel *idcardLab;
@property (weak, nonatomic) IBOutlet UILabel *qqLab;
@property (weak, nonatomic) IBOutlet UILabel *exmainstatueLab;
@property (weak, nonatomic) IBOutlet UILabel *exmainresonLab;
@property (weak, nonatomic) IBOutlet UILabel *exmainedetailLab;
@property (weak, nonatomic) IBOutlet UIButton *changeBtn;
@property (weak, nonatomic) IBOutlet UIButton *deleteBtn;
@property (weak, nonatomic) IBOutlet UILabel *addressLab;
@property (weak, nonatomic) IBOutlet UILabel *lendTimeLab;
@property (weak, nonatomic) IBOutlet UILabel *yinghuanLab;



@end

@implementation CYReleaceDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.headimageView sd_setImageWithURL:CYURLWithService(_cypermodel.photo) placeholderImage:[UIImage imageWithName:@"icon_default_laolai"]];
    self.nameLab.text = [NSString stringWithFormat:@"%@",_cypermodel.name];
    self.idcardLab.text = [NSString stringWithFormat:@"%@",_cypermodel.certificateNo];
    self.phoneLab.text = [NSString stringWithFormat:@"%@",_cypermodel.phone];
    _lendTimeLab.text = [NSString stringWithFormat:@"应还时间:%@", _cypermodel.createTime ];
    _yinghuanLab.text = [NSString stringWithFormat:@"借款时间:%@",_cypermodel.lendTime];
    if (_cypermodel.qq) {
        _qqLab.text = [NSString stringWithFormat:@"qq号:%@",_cypermodel.qq];
    }else{
        _qqLab.text = @"qq号:无";
    }
    _addressLab.text = [NSString stringWithFormat:@"违约人所在地区:%@-%@-%@",_cypermodel.province,_cypermodel.city,_cypermodel.area];
    if (_cypermodel.exmainreson) {
        _exmainresonLab.text = [NSString stringWithFormat:@"审核意见:%@",_cypermodel.exmainreson];
    }else{
        _exmainresonLab.text = @"暂无审核意见";
    }
    self.exmainedetailLab.text = [NSString stringWithFormat:@"  %@于%@向***进行借款，应于%@之前进行还款，至今尚未履行还款义务，现对%@进行网络公示，望引起违约人的重视",_cypermodel.name,_cypermodel.lendTime,_cypermodel.createTime,_cypermodel.name];
    self.exmainstatueLab.text = [NSString stringWithFormat:@"%@",_cypermodel.isExamine];
    
    if (_cypermodel.isExamine.intValue == 1) {
        self.exmainstatueLab.text = @"已通过";
        self.exmainstatueLab.textColor = CYColor(100, 200, 100, 1);
    }
    if (_cypermodel.isExamine.intValue == 0) {
        self.exmainstatueLab.text = @"待审核";
        self.exmainstatueLab.textColor = [UIColor orangeColor];
    }
    if (_cypermodel.isExamine.intValue == -1) {
        self.exmainstatueLab.text = @"未通过";
        self.exmainstatueLab.textColor = [UIColor redColor];
    }

    // Do any additional setup after loading the view from its nib.
}

- (IBAction)changeBtnClick:(id)sender {
    CYCommonReleaseTVC *release = [CYCommonReleaseTVC le_loadFromStoryBoard:[CYJumpsTool mainSB]];
    [self.navigationController pushViewController:release animated:YES];
}

- (IBAction)deleteBtnClick:(id)sender {
    NSString *strid = _cypermodel.createid;
    NSString *type = _cypermodel.isExamine;
    CYLog(@"strid = %@",strid);
    CYLog(@"type = %@",type);
    CYUser *user = [CYLoginHttpTool userData].user;
    
    if (type.intValue == 1 ||type.intValue == -1 ||type.intValue == 2) {
        [CYHttpTool postWithURL:[CYURL shared].deleteNetworkCollectRecord params:@{@"userId":user.userId,@"token":user.token,@"id":strid} success:^(id json) {
            [self.navigationController popViewControllerAnimated:YES];
            
        } failure:^(NSError *error) {
            
        }];
    }else{
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"你无权操作待审核的发布信息" delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
        
        [alertView show];
    }

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
